{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import os\r\n",
    "\r\n",
    "import time\r\n",
    "\r\n",
    "import random\r\n",
    "\r\n",
    "import pygame\r\n",
    "\r\n",
    "import colorama\r\n",
    "\r\n",
    "\r\n",
    "\r\n",
    "BGMPATH = 'bgm.mp3'\r\n",
    "\r\n",
    "colorama.init(convert=True)\r\n",
    "\r\n",
    "STARS = [2, 4, 8, 10, 14, 20, 26, 28, 40, 44, 52, 60, 64, 76]\r\n",
    "\r\n",
    "HEARTS = [13, 27, 41, 55, 69, 77]\r\n",
    "\r\n",
    "FLOWERS = [7, 15, 23, 31, 39, 46]\r\n",
    "\r\n",
    "RED = colorama.Fore.RED + colorama.Style.BRIGHT\r\n",
    "\r\n",
    "CYAN = colorama.Fore.CYAN + colorama.Style.BRIGHT\r\n",
    "\r\n",
    "GREEN = colorama.Fore.GREEN + colorama.Style.BRIGHT\r\n",
    "\r\n",
    "YELLOW = colorama.Fore.YELLOW + colorama.Style.BRIGHT\r\n",
    "\r\n",
    "MAGENTA = colorama.Fore.MAGENTA + colorama.Style.BRIGHT\r\n",
    "\r\n",
    "'''程序背景音乐'''\r\n",
    "\r\n",
    "# def playBGM(bgm_path):\r\n",
    "\r\n",
    "# pygame.mixer.init()\r\n",
    "\r\n",
    "# pygame.mixer.music.load(bgm_path)\r\n",
    "\r\n",
    "# pygame.mixer.music.play(-1)\r\n",
    "\r\n",
    "\r\n",
    "\r\n",
    "def nextLine():\r\n",
    "\r\n",
    "    time.sleep(0.3)\r\n",
    "\r\n",
    "print()\r\n",
    "\r\n",
    "'''画心'''\r\n",
    "\r\n",
    "def drawHeart():\r\n",
    "\r\n",
    "    num_spaces = random.randint(8, 80)\r\n",
    "\r\n",
    "\r\n",
    "\r\n",
    "for i in range(78):\r\n",
    "\r\n",
    "    if i in HEARTS:\r\n",
    "\r\n",
    "        nextLine()\r\n",
    "\r\n",
    "        print(\"* num_spaces, end=\" )\r\n",
    "\r\n",
    "    elif i in STARS:\r\n",
    "\r\n",
    "        print(RED + '*', end='')\r\n",
    "\r\n",
    "    elif i in [31, 35]:\r\n",
    "\r\n",
    "        print(GREEN + '2', end='')\r\n",
    "\r\n",
    "    elif i in [33, 37]:\r\n",
    "\r\n",
    "        print(GREEN + '0', end='')\r\n",
    "\r\n",
    "    else:\r\n",
    "\r\n",
    "        print(' ', end='')\r\n",
    "\r\n",
    "'''显示祝福文字'''\r\n",
    "\r\n",
    "def showText():\r\n",
    "\r\n",
    "    print(' ' * random.randint(8, 80), end='')\r\n",
    "\r\n",
    "    print(CYAN + \"Happy new year!\", end='')\r\n",
    "\r\n",
    "'''画花'''\r\n",
    "\r\n",
    "def drawFlower():\r\n",
    "\r\n",
    "    num_spaces = random.randint(8, 80)\r\n",
    "\r\n",
    "    print(' ' * num_spaces, end='')\r\n",
    "\r\n",
    "    for i in range(47):\r\n",
    "\r\n",
    "        if i in FLOWERS:\r\n",
    "\r\n",
    "            nextLine()\r\n",
    "\r\n",
    "            print(' ' * num_spaces, end='')\r\n",
    "\r\n",
    "        elif i in [2, 8, 12, 18]:\r\n",
    "\r\n",
    "            print(MAGENTA + '{', end='')\r\n",
    "\r\n",
    "        elif i in [3, 9, 13, 19]:\r\n",
    "\r\n",
    "            print(MAGENTA + '_', end='')\r\n",
    "\r\n",
    "        elif i in [4, 10, 14, 20]:\r\n",
    "\r\n",
    "            print(MAGENTA + '}', end='')\r\n",
    "\r\n",
    "        elif i in [27, 35, 43]:\r\n",
    "\r\n",
    "            print(GREEN + '|', end='')\r\n",
    "\r\n",
    "        elif i in [34, 44]:\r\n",
    "\r\n",
    "            print(GREEN + '~', end='')\r\n",
    "\r\n",
    "        elif i == 11:\r\n",
    "\r\n",
    "            print(YELLOW + 'o', end='')\r\n",
    "\r\n",
    "        else:\r\n",
    "\r\n",
    "            print(' ', end='')\r\n",
    "\r\n",
    "'''清屏'''\r\n",
    "\r\n",
    "def clearScreen():\r\n",
    "\r\n",
    "    try:\r\n",
    "\r\n",
    "        os.system('cls')\r\n",
    "\r\n",
    "    except:\r\n",
    "\r\n",
    "        os.system('clear')\r\n",
    "\r\n",
    "'''主程序'''\r\n",
    "\r\n",
    "def main():\r\n",
    "\r\n",
    "# playBGM(BGMPATH)\r\n",
    "\r\n",
    "    clearScreen()\r\n",
    "\r\n",
    "while True:\r\n",
    "\r\n",
    "    drawHeart()\r\n",
    "\r\n",
    "    nextLine()\r\n",
    "\r\n",
    "    showText()\r\n",
    "\r\n",
    "    nextLine()\r\n",
    "\r\n",
    "    nextLine()\r\n",
    "\r\n",
    "    drawFlower()\r\n",
    "\r\n",
    "print()\r\n"
   ],
   "outputs": [
    {
     "output_type": "error",
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'pygame'",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-1-58dafeeca95a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mrandom\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mpygame\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      8\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      9\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mcolorama\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'pygame'"
     ]
    }
   ],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.8.8",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.8 64-bit ('base': conda)"
  },
  "interpreter": {
   "hash": "73e03da126b73bfff3642ec5261d56fa25c444ea595de51041687efaa60dda41"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}